//
//  MK_LivingPlayer.m
//  miku直播
//
//  Created by 杨尚达 on 2017/7/29.
//  Copyright © 2017年 杨尚达. All rights reserved.
//

#import "MK_LivingPlayer.h"

@interface MK_LivingPlayer ()

@end

@implementation MK_LivingPlayer


-(void)loadPlayerViewWithURLStr:(NSString*)urlStr{
    
    if (urlStr == nil) {
        UIButton* errorBu = [UIButton new];
        [errorBu setTitle:@"主播已经下播" forState:UIControlStateNormal];
        [self.view addSubview:errorBu];
        [errorBu mas_makeConstraints:^(MASConstraintMaker *make) {
            make.center.offset(0);
        }];
        return;
    }
    
    IJKMPMoviePlayerController* player = [[IJKMPMoviePlayerController alloc] initWithContentURLString:urlStr];
    player.controlStyle = MPMovieControlStyleNone;
    self.hlsPlayer = player;
    [self.hlsPlayer setScalingMode:IJKMPMovieScalingModeAspectFit];
  
    [self.view insertSubview:self.hlsPlayer.view atIndex:0];
    [self.hlsPlayer.view mas_makeConstraints:^(MASConstraintMaker *make) {
        make.edges.offset(0);
    }];
    //self.hlsPlayer.view.userInteractionEnabled = NO;
    self.hlsPlayer.scalingMode = IJKMPMovieScalingModeAspectFit;
    [self.hlsPlayer prepareToPlay];
    [self.hlsPlayer play];

}



@end
